package com.epoint.juc.single;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Demo {

    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
//        Hungry instance = Hungry.getInstance();
//        Hungry instance2 = Hungry.getInstance();
//        System.out.println(instance);
//        System.out.println(instance2);

//        for(int i = 0; i < 1000; i++){
//            new Thread(()->{
//                LazyMan lazyMan = LazyMan.getInstance();
//                System.out.println(lazyMan);
//            }).start();
//        }
//        LazyMan lazyMan = LazyMan.getInstance();
//        Constructor<LazyMan> declaredConstructor =
//                LazyMan.class.getDeclaredConstructor(null);
//        declaredConstructor.setAccessible(true);
//        LazyMan lazyMan2 = declaredConstructor.newInstance();
//
//        System.out.println(lazyMan);
//        System.out.println(lazyMan2);

        Constructor<LazyMan> declaredConstructor =
                LazyMan.class.getDeclaredConstructor(null);
        declaredConstructor.setAccessible(true);
        LazyMan lazyMan = declaredConstructor.newInstance();
        LazyMan lazyMan2 = declaredConstructor.newInstance();

        System.out.println(lazyMan);
        System.out.println(lazyMan2);


    }

}
